package com.dimples.dd.common.enums;

import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.dimples.dd.common.base.IBaseEnum;
import com.dimples.dd.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 通用状态枚举
 *
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/6/13
 */
@Getter
@AllArgsConstructor
public enum CommonStatusEnum implements IntArrayValuable, IBaseEnum<Integer> {

    ENABLE(1, "开启"),
    DISABLE(0, "关闭");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CommonStatusEnum::getValue).toArray();

    /**
     * 状态值
     */
    @EnumValue
    private final Integer value;
    /**
     * 状态名
     */
    private final String label;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static boolean isEnable(Integer status) {
        return ObjUtil.equal(ENABLE.value, status);
    }

    public static boolean isDisable(Integer status) {
        return ObjUtil.equal(DISABLE.value, status);
    }

}
